package com.mocha.nezha.nezha;

import com.alibaba.fastjson.JSON;
import com.corundumstudio.socketio.SocketIOClient;
import com.mocha.nezha.dmo.VehicleDeleteMessage;
import com.mocha.nezha.dmo.VehiclePathMessage;
import com.mocha.nezha.socket.EventType;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;

import java.util.Set;

/**
 * @author songkui
 * @since 2024/3/21 9:36
 */
@Getter
@Setter
@NoArgsConstructor
@EqualsAndHashCode(of = {"sessionId"})
@Slf4j
public class NezhaClient {

    private SocketIOClient client;
    private String sessionId;
    private String parkCode;

    private String userId;
    private String token;

    private Set<String> cameras; // 摄像头
    private boolean allCamera; // true 表示 当前端  传 ALL 则所有涉嫌偷



    public void sendMessage(VehiclePathMessage message){
        log.info("Send message: sid:{};  {} ", client.getSessionId(), JSON.toJSONString(message));
        client.sendEvent(EventType.PC_VEHICLE_TRACK.event(), message);
    }

    public void sendDeleteMsg(VehicleDeleteMessage message){
        log.info("Send delete vehicle message: sid:{};  {} ", client.getSessionId(), JSON.toJSONString(message));
        client.sendEvent(EventType.PC_VEHICLE_DELETE.event(), message);
    }

}
